import React from 'react';
import './index.css';

export default class DivChecked extends React.Component{
    //个人信息下面的职称方框
    constructor(props){
        super();
        this.state = {
            DivActive:props.DivActive,
            title:props.title,
            id:props.id,
            Change:props.Change
        };
    }
    componentWillReceiveProps(props){
        this.setState({
            DivActive:props.DivActive,
            title:props.title,
            id:props.id,
            Change:props.Change
        })
    }
    clicked = (param)=>{
        return (event)=>{
            this.setState({ 
                DivActive: !this.state.DivActive
            },()=>{
                if(this.props.Change!==undefined){
                    this.props.Change();
                }
            });
        }
    }
    render(){
        return (
            <div id={this.state.id} onClick={this.clicked()} className={ this.state.DivActive?"DivChecked_Out DivActive":"DivChecked_Out"}>
                <span className="DivChecked_Out_Word">{ this.state.title }</span>
                <span className="DivChecked_Out_Sign">√</span>
                <span className="DivChecked_Out_Span"></span>
            </div>
        )
    }
}